from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI(title="Hello FastAPI")


class Item(BaseModel):
    name: str
    price: float
    is_offer: Union[bool, None] = None


# 提交数据
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
    return {"item_name": item.name, "item_id": item_id}
